package club.emergency.wechat.mistake_collection.search.consumer.controller;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.utils.JsonConvert;
import club.emergency.wechat.mistake_collection.search.consumer.service.MistakeCollectionSearchConsumer;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.mistake_collection.search.consumer.controller
 * Date: 2019/2/25
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Api("错题查询接口")
@RestController
@RequestMapping("/mistake-collection-search")
public class MistakeCollectionSearchController {

    private MistakeCollectionSearchConsumer mistakeCollectionSearchConsumer;

    public MistakeCollectionSearchController(MistakeCollectionSearchConsumer mistakeCollectionSearchConsumer) {
        this.mistakeCollectionSearchConsumer = mistakeCollectionSearchConsumer;
    }

    @ApiOperation("按人员查询错题")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "人员id", value = "staffId", dataType = "long", paramType = "query"),
            @ApiImplicitParam(name = "当前页", value = "pageNo", dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "每页显示数据量", value = "pageSize", dataType = "int", paramType = "query")
    })
    @PostMapping("/flipList")
    public ResponseEntity flipList(
            @RequestParam("staffId") Long staffId,
            @RequestParam("pageNo") Integer pageNo,
            @RequestParam("pageSize") Integer pageSize
    ) {
        return new JsonConvert<ResponseEntity>().jsonDecode(mistakeCollectionSearchConsumer.flipList(staffId, pageNo, pageSize), ResponseEntity.class);
    }
}
